package com.ruoyi.project.app.controller;

import com.ruoyi.project.app.response.WordByTypeResponse;
import com.ruoyi.project.app.service.AppWordService;
import com.ruoyi.project.app.util.XResult;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@RestController
@RequestMapping("/app/word")
@Api(tags = "文档接口")
public class AppWordController {
    @Autowired
    private AppWordService service;

    @PostMapping("wordByType")
    @ApiOperation(notes = "wordByType", response = WordByTypeResponse.class, value = "文档接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "文档类型(1.借款合同；2.授信协议)", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "trialAmount", value = "合同-借款金额)", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "installments", value = "合同-借款期数)", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "address", value = "合同-用户地址)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "postalCode", value = "合同-用户邮编)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "purpose", value = "合同-借款用途)", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "backAccount", value = "合同-银行账户)", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "backName", value = "合同-开户银行)", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名)", required = false, dataType = "string", paramType = "query")
    })
    public Object wordByType(@ApiIgnore @RequestAttribute String userId, @ApiIgnore @RequestAttribute String username,
                             @ApiIgnore @RequestParam Map<String, Object> map) throws Exception {
        map.put("userId", userId);
        map.put("username", username);
        return new XResult("获取成功", service.wordByType(map));
    }

}
